from collections.abc import Iterable, Iterator
from typing import TypeVar

from .processing import MLProducer

AnyInput = TypeVar('AnyInput')


class SimpleProducer(MLProducer[AnyInput]):
    def __init__(self, iterable: Iterable[AnyInput] | Iterator[AnyInput]):
        self._iterator = iter(iterable)

    def produce(self) -> AnyInput:
        return next(self._iterator)
